﻿using System;
using System.Collections.ObjectModel;
using System.Windows;
using Automator.Runtime;
using Automator.Runtime.Compiler;

namespace Automator.Tasks.Windows
{
    public partial class ScriptTaskEditWindow : Window
    {
        private ObservableCollection<DummyError> dummy = new ObservableCollection<DummyError>();
        
        public ScriptTaskEditWindow()
        {
            InitializeComponent();
            
            dummy.Add(new DummyError());
        }
        
        private void BtnCompile_Click(object sender, RoutedEventArgs e)
        {
            DynamicCompiler compiler = new DynamicCompiler(
                cmbLanguage.SelectedValue.ToString(),
                edtText.Text,
                SourceType.Script);

            if (compiler.Errors.Count > 0)
                this.lstErrors.ItemsSource = compiler.Errors;
            else
                this.lstErrors.ItemsSource = dummy;
        }
    }
    
    class DummyError
    {
        public string ErrorText { get { return "No error messages"; } }
    }
}